<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>登录界面</title>
    <link href="<?=base_url("templates/default")?>/bootstrap/css/bootstrap.min.css" rel="stylesheet">
		<script src="<?=base_url("templates/default")?>/js/jquery.min.js"></script>
		<script src="<?=base_url("templates/default")?>/bootstrap/js/bootstrap.min.js"></script>
		<link rel="stylesheet" href="<?=base_url("templates/default")?>/css/style.css" />
    <script>
    	$.ajax({
			type: "post",
			url: publicUrl+'login/is_login',
			jsonp: "callback",
			dataType: "jsonp",
			async: false,
			success: function(data) {
				if(typeof(data.is_login) != "undefined"){
					if(data.is_login == 1){
						window.location.href = "index.html";
					}
				}
			}
		});
    </script>
</head>
<body class="login_body">
	<div class="bg"></div>
	<div class="container">
			<div class="row">
				<div class="col-xs-12 title_img"><img class="<?=base_url("templates/default")?>/img-responsive" src="<?=base_url("templates/default")?>/img/mao3.jpg" style="display:block; width:100%; height:100%;"/></div>
			</div>
			<div class="row">
				<div class="col-xs-12 title_h"><h3>用户登录</h3></div>
			</div>
			<form action="<?php echo site_url("login/turnToLogincheck")?>" method="post">
			<div class="row">
				<div class="col-xs-12 title_l">
					<div class="form-group input-group input-group-lg">
						<span class="input-group-addon" id="sizing-addon1"><i class="glyphicon glyphicon-user"></i></span>
						<input type="text" class="form-control" id="user_name" aria-describedby="sizing-addon1" name="telphone" placeholder="请输入手机号" required/>
	    			</div>
					<div class="form-group input-group input-group-lg">
						<span class="input-group-addon" id="sizing-addon2"><i class="glyphicon glyphicon-lock"></i></span>
						<input type="password" class="form-control" id="password" aria-describedby="sizing-addon2" name="password" placeholder="请输入密码" required/>
	    			</div>
	    			<div class="form-group">
		    		<button id="submit" class="btn btn-default btn-block" name="submit" type="submit">登录</button>
	    			</div>
	    		</div>
	    	</form>
			</div>
			<fieldset id="actions">
				<a class="pull-right" href="<?php echo site_url("register/index")?>">注册新用户</a>
			</fieldset>
	</div>
</body>
<script>
	$(document).ready(function(){
		$("#submit").click(function(){
			getajax();
		});
		
		function getajax(){
			var $user_name = $('#user_name').val();
			var $password = $('#password').val();
			var data = {'user_name':$user_name,'password':$password};
			$.ajax({
				type:"get",
				url: publicUrl+"login",
				data: data,
				jsonp:"callback",
				dataType:"jsonp",
				async: false,
				success:function(d){
					if(d.status == 0){
						alert("用户名不存在！！");
					}else if(d.status == 1){
						alert("密码输入错误！！");
					}else if(d.status == 2){
						alert("登录成功！");
						window.location.href = 'index.html';
					}
				}
			});
		}
	});
</script>
</html>